package bjtuoj;

import java.util.Scanner;

/**
 * ClassName: Homework_1_2
 * Description:
 * date: 2021-09-25 19:48
 *
 * @author liyifan
 */
public class Homework_1_B {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int[] prime = new int[]{2, 3, 5, 7};
        int N = scanner.nextInt();
        scanner.close();
        for(Integer i : prime) {
            solution(i, 1, N);
        }
    }

    public static void solution(int x, int level, int length){
        if (level == length){
            System.out.printf("%d\n", x);
            return ;
        }
        for(int i = 1;i <= 9;i++) {
            int temp = x * 10 + i;
            if (isPrime(temp)) {
                solution(temp, level + 1, length);
            }
        }
    }

    public static boolean isPrime(int x){
        if (x == 1 || x == 0)
            return false;
        for(int i = 2;i <= (int)Math.sqrt(x);i++){
            if (x % i == 0) {
                return false;
            }
        }
        return true;
    }
}
